<template>
  <view class="container">
    <!-- 顶部组件 -->
    <u-navbar
      id="nav-bar"
      :is-back="true"
      :background="{ background: '#fff' }"
      :border-bottom="false"
      title=" "
    >
      <view class="segmentedBox">
        <u-subsection
          :list="subsectionList"
          :current="subsectionIndex"
          bgColor="#f5f5f5"
          @change="subsectionChange"
        >
        </u-subsection>
      </view>
    </u-navbar>
    <view class="searchBox">
      <u-search
        class="search"
        placeholder="请输入SN搜索"
        v-model="keyword"
        bgColor="#F7F7F7"
        shape="square"
        @change="searchChange"
      ></u-search>
      <image class="scan" src="/static/images/icon-scan.png" mode="widthFix" />
      <view class="filterBtn" @click="showPopup = true">筛选</view>
    </view>

    <view class="content">
      <view v-if="subsectionIndex === 0" class="order">
        <u-form :model="formModel" ref="uForm" :label-width="280">
          <u-form-item label="订单" :border-bottom="false">
            <u-input
              v-model="formModel.orderNo"
              :disabled="true"
              placeholder="请选择订单"
              @click="showPicker = true"
            />
            <u-icon slot="right" name="arrow-right"></u-icon>
          </u-form-item>
        </u-form>
      </view>

      <view v-if="subsectionIndex === 1" class="order">
        <u-form :model="formModel" ref="uForm" :label-width="280">
          <u-form-item label="伙伴手机号" :border-bottom="false">
            <u-input
              v-model="formModel.phone"
              :disabled="true"
              placeholder="伙伴手机号"
            />
            <view slot="right" class="searchBtn">搜索</view>
          </u-form-item>
        </u-form>
      </view>

      <view class="header">
        <view class="header-in">
          <text>选择机具(共3台)</text>
          <image src="/static/images/icon-tzgg.png" mode="widthFix"></image>
        </view>
        <view class="btn">划拨记录</view>
      </view>

      <view class="list">
        <u-checkbox-group>
          <view class="item">
            <view class="row">
              <u-checkbox v-model="allCheck" shape="circle" :label-disabled="true">
                <view class="checkbox-label">SN:000214656555846</view>
              </u-checkbox>
            </view>
            <view class="row mt25">
              <view class="txt">星云付电签89元激活</view>
              <view class="date">2024-01-02</view>
            </view>
          </view>
        </u-checkbox-group>
      </view>
    </view>
    <view class="bottom">
      <view class="bottom-in">
        <u-checkbox-group>
          <u-checkbox v-model="allCheck" shape="circle" :label-disabled="true">
            <view class="checkbox-label">全选 已选<text>2</text>台</view>
          </u-checkbox>
        </u-checkbox-group>
        <view v-if="subsectionIndex === 0" class="btn">扫码划拨</view>
        <view class="btn1">立即划拨</view>
      </view>
    </view>

    <u-picker
      v-model="showPicker"
      mode="selector"
      :range="selector"
      @confirm="pickerConfirm"
    ></u-picker>

    <u-modal v-model="showModal" width="80%" :showTitle="false" :mask-close-able="false">
      <view slot="default" class="modal">
        <image class="modal-img" src="/static/images/icon-success.png" mode="widthFix" />
        <view class="modal-content">划拨成功！</view>
        <view class="modal-detail">原因</view>
      </view>
    </u-modal>

    <u-popup
      v-model="showPopup"
      mode="bottom"
      width="100%"
      height="auto"
      :closeable="false"
      border-radius="30"
    >
      <view class="popup-content">
        <view class="cancelBtn">取消</view>
        <view class="sureBtn">确定</view>
        <view class="popup-title">筛选条件</view>
        <view class="popup-main">
          <template v-if="subsectionIndex === 1">
            <view class="form-item">
              <u-input
                v-model="formModel.brand"
                :disabled="true"
                :height="62"
                inputAlign="left"
                placeholder="请选择品牌"
                @click="showPicker = true"
              />
              <u-icon name="arrow-right"></u-icon>
            </view>

            <view class="form-item">
              <u-input
                v-model="formModel.model"
                :disabled="true"
                :height="62"
                inputAlign="left"
                placeholder="请选择机型"
                @click="showPicker = true"
              />
              <u-icon name="arrow-right"></u-icon>
            </view>
          </template>

          <view class="form-item">
            <u-input
              v-model="filterModel.beginSn"
              :height="62"
              inputAlign="left"
              placeholder="请输入起始SN号"
          /></view>
          <view class="form-item">
            <u-input
              v-model="filterModel.endSn"
              :height="62"
              inputAlign="left"
              placeholder="请输入终止SN号"
          /></view>
        </view>
      </view>
    </u-popup>
  </view>
</template>
<script>
export default {
  data() {
    return {
      subsectionList: [
        {
          name: '订单划拨',
        },
        {
          name: '伙伴划拨',
        },
      ],
      subsectionIndex: 0,
      formModel: {
        orderNo: '',
        phone: '',
      },
      showPicker: false,
      selector: [1, 2, 3],
      allCheck: false,
      showModal: false,
      showPopup: false,
      filterModel: {
        brand: '',
        model: '',
        beginSn: '',
        endSn: '',
      },
    };
  },
  onLoad() {},
  methods: {
    navigateTo(url) {
      uni.navigateTo({
        url: url,
      });
    },
    subsectionChange(index) {
      this.subsectionIndex = index;
    },
    searchChange(value) {},
    pickerConfirm(value) {},
  },
};
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  min-height: 100vh;
  padding: 0 0 60rpx;
  text-align: center;
  background-color: #f5f5f5;
  .segmentedBox {
    position: absolute;
    top: 10rpx;
    left: 50%;
    transform: translateX(-50%);
    width: 300rpx;
    z-index: 99;
  }
}

.content {
  position: relative;
  width: 100%;
  padding: 0 30rpx;
}

.searchBox {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10rpx 30rpx;
  background-color: #ffffff;
  .search {
    flex: 1;
    min-width: 0;
  }
  .scan {
    margin-left: 10rpx;
    width: 42rpx;
    height: auto;
  }
  .filterBtn {
    margin-left: 16rpx;
    width: 100rpx;
    height: 62rpx;
    line-height: 62rpx;
    font-weight: 400;
    font-size: 28rpx;
    color: #ffffff;
    background: linear-gradient(90deg, #332108, #201403);
    border-radius: 10rpx;
  }
}

.order {
  margin-top: 30rpx;
  padding: 0 30rpx;
  background: #ffffff;
  border-radius: 20rpx;
  .searchBtn {
    font-weight: 400;
    font-size: 28rpx;
    color: #b7926e;
  }
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 30rpx 0;
  .header-in {
    position: relative;
    display: inline-block;
    padding-right: 12rpx;
    text {
      position: relative;
      font-weight: 800;
      font-size: 28rpx;
      color: #333333;
      z-index: 9;
    }
    image {
      position: absolute;
      top: -10rpx;
      right: 0;
      width: 32rpx;
      height: 32rpx;
      background: #f2e3d0;
      border-radius: 50%;
      z-index: 1;
    }
  }
  .btn {
    font-weight: 400;
    font-size: 28rpx;
    color: #b7926e;
    line-height: 1;
  }
}

.bottom {
  position: fixed;
  left: 0;
  bottom: 60rpx;
  width: 100%;
  padding: 0 30rpx;
  .bottom-in {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    .checkbox-label {
      font-weight: 800;
      font-size: 28rpx;
      color: #333333;
      text {
        color: #f03434;
      }
    }
    .btn {
      width: 200rpx;
      height: 74rpx;
      line-height: 74rpx;
      font-weight: bold;
      font-size: 26rpx;
      color: #ffffff;
      text-align: center;
      background: linear-gradient(90deg, #d9b189, #c5a27f);
      border-radius: 12rpx;
    }
    .btn1 {
      margin-left: 16rpx;
      width: 200rpx;
      height: 74rpx;
      line-height: 74rpx;
      font-weight: bold;
      font-size: 26rpx;
      color: #ffffff;
      text-align: center;
      background: linear-gradient(90deg, #332108, #201403);
      border-radius: 12rpx;
    }
  }
}

.list {
  width: 100%;
  overflow: hidden;
  .item {
    float: left;
    margin-bottom: 30rpx;
    width: 100%;
    padding: 30rpx;
    background: #ffffff;
    border-radius: 16rpx;
    .row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      .checkbox-label {
        font-weight: 800;
        font-size: 28rpx;
        color: #333333;
      }
      .txt,
      .date {
        font-weight: 400;
        font-size: 24rpx;
        color: #999999;
      }
    }
  }
}

.mt25 {
  margin-top: 25rpx;
}

.modal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 30rpx;
  line-height: 1;
  .modal-img {
    width: 110rpx;
    height: 110rpx;
  }
  .modal-content {
    margin-top: 20rpx;
    width: 100%;
    font-weight: bold;
    font-size: 28rpx;
    color: #333333;
  }
  .modal-detail {
    margin-top: 20rpx;
    font-weight: 400;
    font-size: 28rpx;
    color: #999999;
    line-height: 1.5;
    width: 100%;
    text-align: center;
  }
}

.popup-content {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0 30rpx 60rpx;
  background-color: #ffffff;
  .cancelBtn {
    position: absolute;
    top: 40rpx;
    left: 30rpx;
    font-weight: 400;
    font-size: 28rpx;
    color: #f53131;
  }
  .sureBtn {
    position: absolute;
    top: 40rpx;
    right: 30rpx;
    font-weight: 400;
    font-size: 28rpx;
    color: #3081f2;
  }
  .popup-title {
    width: 100%;
    height: 110rpx;
    line-height: 110rpx;
    font-size: 32rpx;
    font-weight: bold;
    color: #222222;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
  }
  .popup-main {
    width: 100%;
    .form-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 30rpx;
      width: 100%;
      height: 62rpx;
      padding: 0 30rpx;
      background: #f7f7f7;
      border-radius: 10rpx;
    }
  }
}
</style>
